package com.lc.springboot.mapper;


import com.lc.springboot.model.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author lengchuan <lishuijun1992@gmail.com>
 * @date 16-8-24
 */
@Mapper
public interface UserMapper {

    @Insert("insert into users(name,email,city) values(#{name},#{email},#{city})")
    @SelectKey(before = false,keyProperty = "id",resultType =Integer.class,statement = "SELECT LAST_INSERT_ID()")
    public int saveUser(User user);

    @Delete("delete from users where id = #{id}")
    public void deletUserById(int id);

    @Update("update users set name = #{name}, email = #{email},city = #{city} where id = #{id}")
    public int updateUser(User user);

    @Select("select *from users where id = #{id}")
    public User selectUserById(int id);

    @Select("select * from users")
    public List<User> selectUsers();
}
